package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.view.View;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.db.table.MoveStockScanMasterTable;

import java.util.List;

/**
 * @author: lj
 * Date: 2018/12/24
 * Description:移库倒货装车扫描数据适配器
 */
public class MoveStockLoadScanAdapter extends CommonRecycleAdapter<MoveStockScanMasterTable> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;
    /**
     * 1-左布局，2-有布局
     */
    private int type;

    public MoveStockLoadScanAdapter(Context context, List<MoveStockScanMasterTable> dataList, int layoutId, int type, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, layoutId);
        this.type = type;
        this.mContext = context;
        this.mCommonClickListener = commonClickListener;

    }

    @Override
    public void bindData(CommonViewHolder holder, MoveStockScanMasterTable data, int position) {
        holder.setCommonClickListener(mCommonClickListener);
        if (type == 1) {
            //左布局
            holder.setText(R.id.tv_waybill, data.getWaybillNo());
        } else if (type == 2) {
            //右布局
            holder.setText(R.id.tv_moveOutName, data.getMoveOutName());
            holder.setText(R.id.tv_moveInName, data.getMoveInName());
            holder.setText(R.id.tv_stockNum, data.getStockNum() + "");
            holder.setText(R.id.tv_scanNum, data.getScanCount() + "");
            holder.setText(R.id.tv_diffNum, data.getDiffCount() + "");
        }

        View view = holder.itemView;
        switch (data.getType()) {
            case 0:
                view.setBackgroundColor(mContext.getResources().getColor(R.color.red));
                break;
            case 1:
                view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
                break;
            case 2:
                view.setBackgroundColor(mContext.getResources().getColor(R.color.yellow));
                break;
            case 3:
                view.setBackgroundColor(mContext.getResources().getColor(R.color.green));
                break;
            default:
                break;
        }
    }
}
